<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="../../resources/js/jquery-1.6.js"></script>
	<script type="text/javascript" src="../../resources/js/jquery.form.js"></script>
    <script type="text/javascript" src="../../resources/js/jquery-validation-1.8.0/jquery.validate.js"></script>
    <script type="text/javascript" src="../../resources/js/jquery-validation-1.8.0/additional-methods.js"></script>
    <script type="text/javascript" src="../../resources/js/jquery-ui-1.8.11.custom.min.js"></script>
    <script type="text/javascript" src="../../resources/js/jquery-ui-timepicker-addon.js"></script>
    <link rel="stylesheet" type="text/css" media="screen" href="../../resources/css/start/jquery-ui-1.8.10.custom.css"/>
    <style type="text/css">

        label {
            width: 12em;
            float: left;
        }

        label.error {
            float: none;
            color: red;
            padding-left: .5em;
            vertical-align: top;
        }

        p {
            clear: both;
        }

        .submit {
            margin-left: 12em;
        }

        em {
            font-weight: bold;
            padding-right: 1em;
            vertical-align: top;
        }
    </style>
<script type="text/javascript">
$(document).ready(function() {
$("#editForm").validate({
            submitHandler: function(form) {
                   $(form).ajaxSubmit({
                                        success: function(data) {
                                            if ($.parseJSON(data).isOk) {
                                                if (self!=top) {
                                                alert("Информация по восстановлению вашего пароля была выслана Вам на Email!");
                                                    window.parent.closeIframe(true);
                                                } else {
                                                    window.location="/";
                                                }
                                            } else {
                                                alert("Неверно указан Email!");
                                            }
                                        }
                                    })
                        },
            rules: {
                email: {
                	required: true,
                	remote: "/validation/checkEmailNotFree"
                }
            },
            messages: {
            email: {
            	required: "Это поле обязательно для заполнения",
                remote: jQuery.format("{0} никем не используется")
            }
            }
        });
});

	function recoverPassword() {
	    var email = $("#email").val();
        $.post("/recovery/sendPassword",{email:email},function(data){
           if (data.isOk) {
               alert("Информация по восстановлению вашего пароля была выслана Вам на Email!");
               window.parent.closeIframe(false);
           } else {
               alert("Неверно указан Email!");
        }},'json')
	}
</script>
</head>
<body>


<form id="editForm" method="post" action="/recovery/sendPassword">
	<label for="email">Введите Ваш Email:</label><em></em>
	<input id="email" type="text" name="email"/>
	<input type="submit" value="Восстановить"/>
</form>

</body>
</html>